#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTimer>
#include <QTime>
#include <QTableWidget>
#include <QFileDialog>
#include <QDesktopServices>
#include <QMessageBox>
#include <QAxObject>
#include <QPaintEvent>
#include "login.h"
#include "systemfile.h"
#include "camera.h"
#include "datebase.h"
#include "filemanage.h"
#include "datebase.h"
#include "network.h"
#include "car_product.h"
#include "scrollarea.h"
#include "ledtcp.h"
#include "excelengine.h"
#include "user.h"
#include "seat.h"
#include "userdown.h"
#include "camerajson.h"
enum STATUS{CARIN=1,CAROUT=2};
enum DIRSTATUS{DIRLOCAL=1,DIRTEMP=2};
class Carployee
{
public:
    Carployee(): carFlag() {}

    Carployee( const QString &carName, const QDateTime&surTime)
        : carFlag(carName), carTime(surTime)
    {}
    QString carName() const { return carFlag; }
    QDateTime surTime() const { return carTime; }
private:
    QString carFlag;
    QDateTime carTime;
};

typedef struct
{
  QString AllCarNum;     //返回
  QString FreeCarNum;
  QString InCarNum; //停车开始
  QString OutCarNum;
}park_status;

typedef struct
{
  QString User;     //返回
  QString ParkTime;
  QString CarNum; //停车开始
  QString Money;
}park_shift;


typedef struct
{
  QString freeTime;     //返回
  QString freeTime2;
  QString AddFreeTime; //停车开始
  QString AddDayTime;
}park_fee;

typedef struct
{
  QString ID;     //返回
  QString ParkType;
  QString Fee; //停车开始
}FeeMessage;
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    typedef QMap <QString,Carployee> CarParkMap; //自定义一个map类型，值为EmployeeMap对象
        CarParkMap car_map;
    bool eventFilter(QObject *obj, QEvent *event);
    void closeEvent( QCloseEvent * event );
    void paintEvent(QPaintEvent *);

private:
    Ui::MainWindow *ui;
    QTextCodec *gb2312,*utf8;
    park_status statusInfo;
    park_shift shiftInfo;
    bool isListFreeOpen;
    Login *loginDilog;
    User *userDilog;
    camera *cameraIn,*cameraOut;
    CameraJson *cameraJsonIn;
    FileManage *filelink;
    datebase *myDb;
    network *my_network;
    Car_Product *down_network;
    scrollarea *scroll;
    ledTcp *udpLed;
    QPixmap inPixmap,outPixmap,inRecordPixmap,outRecordPixmap,InParkPixmap;
    QString Camera_picIn,Camera_picOut;
    QDateTime TurnClassTime;
    QString Car_InVehicle,Car_OutVehicle;
    bool carNumberIn_flag,carNumberOut_flag;
    int pass_flag_heart;
    ticketCheck_t Car_OutInfor;
    QTimer *timer_update,*timer_update2,*timer_in,*timer_out,*timer_CarDown,*timer_recordDown,*timer_recordup,*timer_bind_down,*timer_stall_down,*timer_quit_carNumberIn,*timer_quit_carNumberOut,*Timer_bg;
    ExcelEngine excel;
    bool tool_FeeFreeBool,tool_Fee24Bool;
    bool tool_SysLinIn,tool_SysPassTimeCar,tool_SysFeeCarOut,tool_SysPrint,tool_SysCarHan,tool_SysFee,tool_SysBack,tool_SysAllCar,tool_SysUser,tool_SysSeat,tool_SysTopFee;
    int FeeId;
    FeeMessage feeInfo;
    QDateTime ClassTime;

    Seat *seatDilog;
    bool WuPaiCarFlag,CarOutFlag;
    UserDown *down_user;
public slots:
    void init();
    void init_textBrowser();
    void initCamera();
    void init_Status(park_status *info);
    void init_Shift(park_shift *info);
    void bzeroInfo(displayData_t &info);
    void makeAudio(displayData_t &info);
    void TimefinishedSlot(QNetworkReply *reply);
    void CarfinishedSlot4(QNetworkReply *reply);
    void InOutfinishedSlot6(QNetworkReply*);
    void carstallfinishedSlot(QNetworkReply*);
    void carbindfinishedSlot(QNetworkReply*);
    void carNumberIn_Slot(QString carNum, QPixmap *pic) ;
    void carNumberOut_Slot(QString carNum, QPixmap *pic) ;
    int showMap(QString car_no,QString carFlag);
    void map_carLink();
    void CarDownProcess(bool flag);
    void info_downLink();
    void seatbind_downLink();
    void info_upLink();
    void car_stall_downLink();
    void camera_in(); //入口起杆
    void camera_out(); //出口起杆
    void quit_carNumberIn();
    void quit_carNumberOut();
    void initPaint();
    void initTimer();
    void dispUpdata();
    void dispUpdata2();
    void initWeb();
    void ExcleToWidgetCarManage();
    void WidgetCarManageToExcle();
    /********张超************/
private slots:
    void WindowSlot();
    void CarInSlot();
    void ListShow();
    void TurnClass();
    void SearchSlot();
    void SysSlot();
    void windowShow(bool flag);
    void SearchCarSlot();
    void SearchRecordSlot();
    void SearchFeeSlot();
    void SysCarSlot();
    void SysSeatSlot();
    void SysFeeSlot();
    void SysUserSlot();
    void SysSetSlot();
    QString CameraIp(QString flag);
    void Camera_LinkIn();
    void Camera_LinkOut();
    void initFile();
    void Car_downLink();
    void on_toolButton_InCar_clicked();
    void on_toolButton_OutCar_clicked();
    void on_toolButton_OpenIn_clicked();
    void on_toolButton_FreeOut_clicked();
    void on_toolButton_SysLinIn_clicked();
    void on_toolButton_SysPassTimeCar_clicked();
    void on_toolButton_SysFeeCarOut_clicked();
    void on_toolButton_SysPrint_clicked();
    void on_toolButton_SysCarHan_clicked();
    void on_toolButton_SysFee_clicked();
    void on_toolButton_SysBack_clicked();
    void on_toolButton_SysAllCar_clicked();
    void on_toolButton_SysUser_clicked();
    void on_toolButton_SysSeat_clicked();
    void on_toolButton_SysTopFee_clicked();
    void on_toolButton_FeeFreeBool_clicked();
    void on_toolButton_Fee24Bool_clicked();
    void Record_InOutPicShow(QString inPic,QString outPic);
    void on_tableWidget_Record_doubleClicked(const QModelIndex &index);
    void on_tableWidget_SrearchFeeRecord_doubleClicked(const QModelIndex &index);
    void on_pushButton_CarManageNew_clicked();
    void on_pushButton_NewCarQuit_clicked();
    void on_pushButton_UserNew_clicked();
    void sysTemReset();

    void tableWidget_Seat_Show();
    void tableWidget_Fee_Show();
    void tableWidget_User_Show();
    void on_pushButton_SysOk_clicked();
    QString getFeeTime(QString fee);
    void on_tableWidget_Fee_clicked(const QModelIndex &index);
    void on_pushButton_FeeItemOk_clicked();
    void on_pushButton_FeeOk_clicked();
    void on_tableWidget_User_doubleClicked(const QModelIndex &index);  
    void runTimerOut();
    void on_pushButton_NewCarOk_clicked();
    void on_comboBox_NewCarType_activated(const QString &arg1);
    void on_comboBox_NewGuCarType_activated(const QString &arg1);
    void on_pushButton_CarManageClear_clicked();
    void on_lineEdit_CarManageNo_textChanged(const QString &arg1);
    void car_vehicle(QString car_no,QString car_type);

    /******张杰******/
    void on_toolButton_SearchCar_clicked();
    void on_pushButton_CarNoSearch_clicked();
    void on_toolButton_SearchRecord_clicked();
    void on_pushButton_RecordFind_clicked();
    void on_toolButton_SearchFeeRecord_clicked();
    void on_pushButton_FeeRecordSelct_clicked();
    void on_pushButton_FeeRecordOut_clicked();
    void on_tableWidget_SrearchFeeRecord_clicked(const QModelIndex &index);
    void on_pushButton_RecordOut_clicked();
    void on_tableWidget_Record_clicked(const QModelIndex &index);
    /*********************/
    /********张超**********/
     void on_pushButton_SeatNew_clicked();
     void on_pushButton_SeatClear_clicked();
     void on_pushButton_OK_clicked();
     void on_pushButton_FeeFreeOk_clicked();
     void on_pushButton_SysRestart_clicked();
     bool carInSys(QString);
     /********张杰*************/
     void on_toolButton_NoCar_clicked();
     void on_toolButton_1Hour_clicked();
     void on_toolButton_1_2Hour_clicked();
     void on_toolButton_2_4Hour_clicked();
     void on_toolButton_24Hour_clicked();
     void find_car(int falg, QString car_no, QString car_type, int min_time, int max_time);
     void on_tableWidget_CarIn_clicked(const QModelIndex &index);
     void on_toolButton_CarInPark_clicked();
     void on_toolButton_10_clicked();
     void on_toolButton_ParkInOK_clicked();

     void on_toolButton_NoCarIn_clicked();
     void HandCarIn(QString car_no);
     void WuPaiCarRecive();
     void CarOutRecive(QString car_no);
     void on_listWidget_FreeFee_clicked(const QModelIndex &index);

signals:
  void WuPaiCarSend();
  void CarOutSend(QString car_no);
};

#endif // MAINWINDOW_H
